﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using JigLibX.Math;
using JigLibX.Physics;
using JigLibX.Geometry;
using JigLibX.Collision;
using TerrainGenerator.Physics;

namespace TerrainGenerator
{
    class GolfBall : SphereObject
    {
        public GolfBall(Game game, Vector3 position): base(game, position, 1.0f)
        {
            skin.callbackFn += new CollisionCallbackFn(HandleCollisionDetection);
        }

        public bool HandleCollisionDetection(CollisionSkin owner, CollisionSkin other)
        {
            body.AngularVelocity *= 0.75f;
            return true;
        }

        public void ApplyForce(float power, Vector3 direction)
        {
            Body.SetActive();
            direction.Normalize();
            //Body.AddBodyForce(direction * power);
            Body.Velocity = direction * power;
        }

        public void SetPosition(Vector3 position)
        {
            Body.ClearForces();
            Body.Position = position;
        }

        public bool IsActive()
        {
            return Body.IsActive;
        }
    }
}
